plat/arm: Fix incorrect bounds check in ARM_CASSERT_MMAP
authorChris Kay <[email protected]>
Wed, 9 May 2018 14:46:07 +0000 (15:46 +0100)
committerChris Kay <[email protected]>
Fri, 11 May 2018 13:55:20 +0000 (14:55 +0100)
The bounds check in ARM_CASSERT_MMAP does not take into account the
array sentinel in plat_arm_mmap. This commit fixes this, and adds an
additional check to ensure the number of entries in the array is
within the bounds of PLAT_ARM_MMAP_ENTRIES.

Change-Id: Ie6df10c0aa0890d62826bc3224ad7b3e36fd53e2
Signed-off-by: Chris Kay <[email protected]>
include/plat/arm/common/plat_arm.h

index 612a63a8c6112a30ddd0db1a74c48bffdd997e61..fc3f4ec3a7fc0a9eba501d8440700bea0a7f174d 100644 (file)
@@ -59,9 +59,11 @@ typedef struct arm_tzc_regions_info {
                PLAT_ARM_TZC_NS_DEV_ACCESS}
 #endif
 
-#define ARM_CASSERT_MMAP                                               \
-       CASSERT((ARRAY_SIZE(plat_arm_mmap) + ARM_BL_REGIONS)            \
-               <= MAX_MMAP_REGIONS,                                    \
+#define ARM_CASSERT_MMAP                                                 \
+       CASSERT((ARRAY_SIZE(plat_arm_mmap) - 1) <= PLAT_ARM_MMAP_ENTRIES, \
+               assert_plat_arm_mmap_mismatch);                           \
+       CASSERT((PLAT_ARM_MMAP_ENTRIES + ARM_BL_REGIONS)                  \
+               <= MAX_MMAP_REGIONS,                                      \
                assert_max_mmap_regions);
 
 /*